﻿

//初始化
if (typeof ($) != "undefined") {
    var fun = getPar1("fun");
    $(document).ready(function () {

    });

    //debugger;
    if (fun == "view") {
        GetEmpNameByEmpID(instance[0].EmployeeID);
        parent.document.getElementById("yui-gen7-button").style.display = "none";
        $("div input").attr("disabled", true).css("background", "whitesmoke");
        $("div select").attr("disabled", true).css("background", "whitesmoke");
        $("div button").hide();
    }
}


//选择员工
var employeeId;
var ValueChanged = function () {
    employeeId = $("#empId").val();
}

var TextChanged = function () {
    var employeeName = $("#txtempId").val();
    if (employeeId == "" || employeeId == "undefined") {
        return;
    }
    if (employeeName == "" || employeeName == "undefined") {
        return;
    }
    //debugger
    $("input[name='txtEmployeeID']").last().val(employeeName);
    $("input[name='EmployeeID']").last().val(employeeId);
    GetEmpcodeByEmpID(employeeId);
}

//获取员工编号
function GetEmpcodeByEmpID(empId) {
    var url = "../Extend/AjaxData/jsonlist.aspx?entity=V_hrEmployee&condition=ID='" + empId + "'";
    $.get(url, function (d, s) {
        var list = eval("(" + d + ")");

        for (var o in list.rows) {
            var t = list.rows[o].EmployeeCode;
            if (typeof (t) != "undefined") {
                $("input[name='EmployeeCode']").last().val(t);
            }
        }

    });
}

//获取员工姓名
function GetEmpNameByEmpID(empId) {
    var url = "../Extend/AjaxData/jsonlist.aspx?entity=V_hrEmployee&condition=ID='" + empId + "'";
    $.get(url, function (d, s) {
        var list = eval("(" + d + ")");

        for (var o in list.rows) {
            var t = list.rows[o].CName;
            if (typeof (t) != "undefined") {
                $("input[name='txtEmployeeID']").last().val(t);
            }
        }

    });
}

var fnCheckData = function () {
    try {
        if ($("#txtEmployeeID").val() == "") {
            return "员工姓名不能为空！";
        }
        if ($("#EmployeeCode").val() == "") {
            return "员工编号不能为空！";
        }

        var ss = $("#CardDate").val();
        if (!isDateFormat(ss)) {
            return "打卡日期输入错误！";
        }

        var tempTime = $("#CardTime").val() + ":01";
        if (!isTime(tempTime)) {
            return "打卡时间格式不对!";
        }

    }
    catch (e)
     { }
}

